package cn.hn.tx.rebot.poll.service.impl;

import java.util.Iterator;
import java.util.List;

import cn.hn.comm.ibatis.BaseDAO;
import cn.hn.tx.rebot.poll.model.RebotPoll;
import cn.hn.tx.rebot.poll.model.RebotPollOption;
import cn.hn.tx.rebot.poll.service.IRebotPollService;

public class RebotPollServiceImpl implements IRebotPollService {

	final String NAMESPACE = "cn.hn.tx.rebot.poll.dao";

	// DAO基类
	private BaseDAO baseDAO;

	public Integer insertRebotPoll(RebotPoll rebotPoll) {
		return (Integer) baseDAO
				.insert(NAMESPACE, "insertRebotPoll", rebotPoll);
	}

	public void insertRebotPollOption(List<RebotPollOption> pollOptions) {
		Iterator<RebotPollOption> itera = pollOptions.iterator();
		while (itera.hasNext()) {
			baseDAO.insert(NAMESPACE, "insertRebotPollOption", itera.next());
		}

	}

	public List<RebotPoll> queryListRebotPollBySubject(String subject) {
		return baseDAO.queryList(NAMESPACE, "queryListRebotPollBySubject", subject);
	}

	public void updateRebotPoll(RebotPoll rebotPoll) {
		baseDAO.update(NAMESPACE, "updateRebotPoll", rebotPoll);
	}

	public RebotPoll queryRebotPollByPid(int pid) {
		return (RebotPoll)baseDAO.query(NAMESPACE, "queryRebotPollByPid", pid);
	}

	public List<RebotPoll> queryListRebotPollByPid(int pid) {
		return (List<RebotPoll>)baseDAO.query(NAMESPACE, "queryListRebotPollByPid", pid);
	}

	public List<RebotPollOption> queryListRebotPollOptionByPid(int pid) {
		return baseDAO.queryList(NAMESPACE, "queryListRebotPollOptionByPid", pid);
	}

	public BaseDAO getBaseDAO() {
		return baseDAO;
	}

	public void setBaseDAO(BaseDAO baseDAO) {
		this.baseDAO = baseDAO;
	}

}
